<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册页面</title>
</head>
<style>
    body {
        background-repeat: repeat;
        background-size: 100%;
    }

    .container {
        width: 500px;
    }
</style>
<body>
<div class="container">
    <h2>系统用户注册</h2>
    <form id="register_form">
        <div class="form-group">
            <label for="userName">用户名：</label>
            <input class="form-control" id ="userName" name="userName" placeholder="请输入用户名/账号">
            <label for="userPassword">密码：</label>
            <input type="password" class="form-control" id="userPassword" name="userPassword" placeholder="请输入密码">
            <label for="userRealName">真实姓名：</label>
            <input class="form-control" id="userRealName" name="userRealName" placeholder="请输入真实姓名">
            <label class="userSex">性别：<input type="radio" name="userSex" checked value="1">男</label>
            <label class="userSex"><input type="radio" name="userSex" value="0">女</label>
            <label for="userEmail">邮箱：</label>
            <input type="email" class="form-control" id="userEmail" name="userEmail" placeholder="请输入邮箱">
            <label for="userMobile">电话：</label>
            <input class="form-control" id="userMobile" name="userMobile" placeholder="请输入电话号">
            <label for="userSDate">起始时间：</label>
            <input type="date" class="form-control" id="userSDate" name="userSDate">
            <label for="userEDate">结束时间：</label>
            <input type="date" class="form-control" id="userEDate" name="userEDate">
            <label for="Status">状态：</label>
            <select class="form-control" id="Status" name="Status">
                <option value="青铜">青铜</option>
                <option value="白银">白银</option>
                <option value="黄金">黄金</option>
                <option value="钻石">钻石</option>
                <option value="紫金">紫金</option>
                <option value="黑金">黑金</option>
            </select>
            <label for="subShopID">分销商id：</label>
            <input class="form-control" id="subShopID"  name="subShopID" placeholder="请输入分销商id：">
        </div>
        <button type="button" class="btn btn-primary" id="register_btn">注册</button>
    </form>
</div>


<script src="style/js/jquery3.6.js"></script>
<script src="style/js/vue.js"></script>
<script>
    $("#userName").change(function (){
        $.ajax({
            type:"post",
            url:"UserController/registerSel",
            data:$("#register_form").serialize(),
            dataType:"json",
            success:function (data) {
                if (data == 1) {
                    alert("账号已存在，请重新输入")
                }
            }
        })
    })
    $("#register_btn").click(function () {
        $.ajax({
            type:"post",
            url:"UserController/register",
            data:$("#register_form").serialize(),
            dataType:"json",
            success:function (data) {
                if(data==1){
                    alert("注册成功")
                    location.href="login.html"
                }else{
                    alert("注册失败")
                }
            }
        })
    })
</script>
</body>
</html>